<?php

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/**
  * @author Flavio de Vasconcellos Correa
  * @since 2008/07/08
  * @package EasyActionPHP
  * @version $id$
  */
class EasyActionPHP {

    /**
     * @var        string Base directory to use for autoloading. Initialized in self::initBaseDir()
     */
    protected static $baseDir;
    protected static $autoloadMap = array(
        'EasyActionPHP\Controller\AbstractAction' => 'Controller/AbstractAction.php'
        , 'EasyActionPHP\Controller\AbstractActionForm' => 'Controller/AbstractActionForm.php'
        , 'EasyActionPHP\Controller\AbstractFormBean' => 'Controller/AbstractFormBean.php'
        , 'EasyActionPHP\Controller\ActionController' => 'Controller/ActionController.php'
        , 'EasyActionPHP\Controller\ActionForward' => 'Controller/ActionForward.php'
        , 'EasyActionPHP\Controller\ActionForwardMapping' => 'Controller/ActionForwardMapping.php'
        , 'EasyActionPHP\Controller\ActionInterceptor' => 'Controller/ActionInterceptor.php'
        , 'EasyActionPHP\Controller\HttpRequest' => 'Controller/HttpRequest.php'
        , 'EasyActionPHP\Controller\HttpResponse' => 'Controller/HttpResponse.php'
        , 'EasyActionPHP\Core\ActionResourceBundle' => 'Core/ActionResourceBundle.php'
        , 'EasyActionPHP\Core\Application' => 'Core/Application.php'
        , 'EasyActionPHP\Core\PBean' => 'Core/PBean.php'
        , 'EasyActionPHP\Dispatcher\ActionDispatcher' => 'Dispatcher/ActionDispatcher.php'
        , 'EasyActionPHP\Dispatcher\ActionTemplateSingleton' => 'Dispatcher/ActionTemplateSingleton.php'
        , 'EasyActionPHP\Exception\ActionException' => 'Exception/ActionException.php'
        , 'EasyActionPHP\Exception\IvalidActionException' => 'Exception/IvalidActionException.php'
        , 'EasyActionPHP\Exception\IvalidClassException' => 'Exception/IvalidClassException.php'
        , 'EasyActionPHP\Exception\IvalidForwardCallException' => 'Exception/IvalidForwardCallException.php'
        , 'EasyActionPHP\Exception\IvalidMethodException' => 'Exception/IvalidMethodException.php'
        , 'EasyActionPHP\Exception\IvalidObjectException' => 'Exception/IvalidObjectException.php'
        , 'EasyActionPHP\Exception\IvalidParameterException' => 'Exception/IvalidParameterException.php'
        , 'EasyActionPHP\Exception\IvalidResourceException' => 'Exception/IvalidResourceException.php'
        , 'EasyActionPHP\Exception\OutOfBoundsException' => 'Exception/OutOfBoundsException.php'
        , 'EasyActionPHP\Exception\SessionConfigException' => 'Exception/SessionConfigException.php'
        , 'EasyActionPHP\Forms\ActionFormMapping' => 'Forms/ActionFormMapping.php'
        , 'EasyActionPHP\Log\ActionLogger' => 'Log/ActionLogger.php'
        , 'EasyActionPHP\Log\FileAppender' => 'Log/FileAppender.php'
        , 'EasyActionPHP\Log\LoggerLevel' => 'Log/LoggerLevel.php'
        , 'EasyActionPHP\Util\ActionErrors' => 'Utils/ActionErrors.php'
        , 'EasyActionPHP\Util\ActionUtil' => 'Utils/ActionUtil.php'
        , 'EasyActionPHP\Util\QuickSortUtil' => 'Utils/QuickSortUtil.php'
    );

    /**
     * Initialize the base directory for the autoloader.
     * Avoids a call to dirname(__FILE__) each time self::autoload() is called.
     */
    public static function initBaseDir() {
        self::$baseDir = dirname(__FILE__) . '/';
    }

    /**
     * Autoload function for loading EasyActionPHP dependencies.
     *
     * @param      string The class name needing loading.
     *
     * @return boolean TRUE if the class was loaded, false otherwise.
     * 
     * @see Propel Project
     */
    public static function autoload($className) {
        if (isset(self::$autoloadMap[$className])) {
            require_once self::$baseDir . self::$autoloadMap[$className];

            return true;
        }

        return false;
    }

}

EasyActionPHP::initBaseDir();
spl_autoload_register(array('EasyActionPHP', 'autoload'));
?>
